package com.foreknow.demo5;

/**
 * 计算1+...n的偶数和
 * 用方法实现
 */
public class MethodDemo5 {
    public static int sum(int n){
        int sum = 0;
        for (int i = 1;i<100;i++){
            if (i%2==0){
                sum+=i;
            }

        }
//        System.out.println(sum);
        return sum;
    }
    public static void main(String[] args) {
        int sum =MethodDemo5.sum(100);
        System.out.println(sum);
    }
}
